﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using Agility.Web.Resources;
using System.ServiceModel.DomainServices.Server;
using System.Data.Objects.DataClasses;
using System.Text;
using System.Globalization;

namespace Agility.Web.Models.DomainModel
{
    [MetadataType(typeof(EpicMetadata))]
    public partial class Epic
    {
        public override string ToString()
        {
            StringBuilder output = new StringBuilder("Epic data:\r\n");
            output.AppendLine(string.Format(CultureInfo.InvariantCulture, "\t\tId:\t\t{0}", this.Id.ToString()));
            output.AppendLine(string.Format(CultureInfo.InvariantCulture, "\t\tTitle:\t\t{0}", this.Title));
            output.AppendLine(string.Format(CultureInfo.InvariantCulture, "\t\tDescription:\t{0}", this.Description));
            output.AppendLine(string.Format(CultureInfo.InvariantCulture, "\t\tCreationDate:\t{0}", this.CreationDate));
            output.AppendLine(string.Format(CultureInfo.InvariantCulture, "\t\tRequestedBy:\t{0}", this.RequestedBy));
            return output.ToString();
        }
        public class EpicMetadata
        {
            [Key]
            [Editable(false, AllowInitialValue=true)]
            [Display(AutoGenerateField = false)]
            public Guid Id { get; private set; }

            [Required(AllowEmptyStrings = false, ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]
            [StringLength(30, ErrorMessageResourceName = "ValidationErrorEpicTitleLength", ErrorMessageResourceType = typeof(ValidationErrorResources))]
            [Display(AutoGenerateField = true, Order = 1, ResourceType = typeof(EpicResources), Name = "EpicTitle")]
            public string Title { get; set; }

            [Required(AllowEmptyStrings = false, ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]
            [StringLength(250, ErrorMessageResourceName = "ValidationErrorEpicDescriptionLength", ErrorMessageResourceType = typeof(ValidationErrorResources))]
            [Display(AutoGenerateField = true, Order = 2, ResourceType = typeof(EpicResources), Name = "EpicDescription")]
            [DataType(DataType.MultilineText)]
            public string Description { get; set; }

            [Required]
            [Editable(false, AllowInitialValue=true)]
            [Display(AutoGenerateField = true, Order = 0, ResourceType = typeof(EpicResources), Name = "EpicCreationDate")]
            [DataType(DataType.Date)]
            public DateTime CreationDate { get; private set; }

            [Required]
            [Editable(false, AllowInitialValue = true)]
            [Display(AutoGenerateField = true, Order = 3, ResourceType = typeof(EpicResources), Name = "EpicRequestedBy")]
            public string RequestedBy { get; private set; }

            //[Association("EpicEpicAssessment", "Id", "Id", IsForeignKey = true)]
            //public EntityReference<EpicAssessment> AssessmentReference { get; private set; }
        }
    }

}